package com.bytearch.fast.cloud.algorithm.demo;

import java.nio.charset.StandardCharsets;

/**
 * 分治
 */
public class seperate {
    /**
     * 求x的n次幂
     * @param x
     * @param n
     * @return
     */
    public static long pow(int x , int n) {
        if (n == 1) return x;
        if (n % 2 == 0) {
            //偶数
           return pow(x, n/2) * pow(x, n/2);
        } else {
            //奇数
            return pow(x, n/2) * pow(x, n/2) * x;
        }
    }
    public static char[] toUpCase(char[] arr, int i) {
        if (i >= arr.length) {
            return arr;
        }
        arr[i] = toUpCaseUtil(arr[i]);
        return toUpCase(arr, i+1);
    }

    public static char toUpCaseUtil(char c) {
        if (c < 97 || c > 122) {
            return ' ';
        }
        return (char) (c - 32);
    }
    public static void main(String[] args) {
        System.out.println(pow(2, 10));
        try {
            System.out.println( toUpCase(new char[] {'a', 'b', 'c'}, 0));
        } catch (Exception e) {

        }
    }
}
